package gold.digger;

import gold.vo.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC538 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public TreeNode convertBST(TreeNode root) {
            convertBSTRecur(root, 0);
            return root;
        }

        public int convertBSTRecur(TreeNode root, int addValue) {
            if (null == root) return addValue;
            root.val += convertBSTRecur(root.right, addValue);
            return convertBSTRecur(root.left, root.val);
        }
    }

    public void run() {
        Solution solution = new Solution();
        List<Integer> list = new ArrayList<>();
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC538 an = new LC538();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
